import type { PlusColumn } from '@wlydfe/pro-ui'
import { useEnum } from '@/composables/enum/useEnum'
import { maskName, maskPhoneNumber } from '@/utils/format'

const {
  [CommonDictEnum.WAYBILL_LOAN_INTENTION_SOURCE]: waybillLoanSourceOptions,
  [CommonDictEnum.WAYBILL_LOAN_INTENTION_STATUS]: waybillLoanIntentionStatusOptions,
} = useEnum([
  CommonDictEnum.WAYBILL_LOAN_INTENTION_SOURCE,
  CommonDictEnum.WAYBILL_LOAN_INTENTION_STATUS,
])

export const tableConfig: PlusColumn[] = [
  {
    label: '意向企业',
    prop: 'companyName',
    width: 200,
    hideInSearch: false,
  },
  {
    label: '企业注册地',
    prop: 'companyRegisterAddress',
    width: 200,
  },
  {
    label: '注册时间',
    prop: 'companyRegisterTime',
    width: 160,
  },
  {
    label: '归属省公司',
    prop: 'bizCompanyName',
    width: 200,
  },
  {
    label: '销售姓名',
    prop: 'salesName',
    width: 150,
  },
  {
    label: '联系人',
    width: 160,
    hideInSearch: false,
    prop: 'contactName',
    render: (value: string) => maskName(value),
  },
  {
    label: '联系电话',
    prop: 'contactPhone',
    width: 120,
    render: (value: string) => maskPhoneNumber(value),
  },
  {
    label: '职务',
    prop: 'contactPosition',
    width: 160,
  },
  {
    label: '资金需求额度',
    prop: 'keyDemand',
    width: 160,
  },
  {
    label: '来源',
    prop: 'source',
    width: 160,
    valueType: 'select',
    options: waybillLoanSourceOptions,
  },
  {
    label: '登记时间',
    prop: 'createdDate',
    width: 180,
    hideInSearch: false,
    valueType: 'date-picker',
    fieldProps: {
      type: 'daterange',
      startPlaceholder: '开始时间',
      endPlaceholder: '结束时间',
      rangeSeparator: '至',
    },
  },
  {
    label: '评估结果',
    prop: 'evaluateResult',
    width: 140,
    valueType: 'select',
    options: evaluateResultOptions,
  },
  {
    label: '风险等级',
    prop: 'riskLevel',
    width: 140,
  },
  {
    label: '评分',
    prop: 'score',
    width: 140,
  },
  {
    label: '授信金额',
    prop: 'creditAmount',
    width: 160,
  },
  {
    label: '风险评估详情',
    prop: 'riskDetail',
    width: 140,
  },
  {
    label: '状态',
    prop: 'status',
    hideInSearch: false,
    width: 140,
    valueType: 'select',
    options: waybillLoanIntentionStatusOptions,
  },
]
